using System;
using MidnightPeach.Engine.Generators.ServiceGenerators;
using System.Linq;

namespace MidnightPeach.Engine.Schema.ServiceSchema
{
    public class Parameter : SchemaElement
    {
        public Parameter(string name, Method method, Type type)
            : base(name)
        {
            Method = method;
            _type = type;
        }

        public Method Method { get; private set; }

        public string TypeName
        {
            get
            {
                if (_type == typeof(void))
                {
                    return "void";
                }
                else if (_type.IsGenericType == false)
                {
                    return _type.Name;
                }
                else
                {
                    return InfoClassUtility.Convert(_type);
                }
            }
        }

        private readonly Type _type;
    }
}
